$(function() {
	FastClick.attach(document.body);
});

var superviseSummary = new Vue({
	el: "body",
	data: {
		userid: "",
		nowYear: "",
		summaryTotal: "", //当前汇总信息
		nowTimeString: "", //当前时间字符串
		summaryTotalDepart: "", //部门分类
		summaryTotalWorkType: "", //工作类别
		summaryTotalXiuGai: "", //修改类别
		summaryTotalChaoShi: "" //超时任务
	},
	created: function() {
		_this = this; //防止出现闭包
		_this.userid = getUrlItem("userid"); //用户id
		var time = new Date();
		var year = time.getFullYear();
		var month = time.getMonth() + 1;
		var day = time.getDate()
		var hour = time.getHours()
		var min = time.getMinutes()
		_this.nowTimeString = year + "-" + (month > 9 ? month : "0" + month) + "-" + (day > 9 ? day : "0" + day) + "&nbsp;&nbsp;" + (hour > 9 ? hour : "0" + hour) + "：" + (min > 9 ? min : "0" + min)
		_this.nowYear = time.getFullYear();
		getSummaryTotal(_this)

		_this.$nextTick(function() {
			setTimeout(function() {
				$(".supervise-summary-body").removeClass("hidden")
				$(".loader").addClass("hidden")
			}, 200)
		})
	},
	methods: {
		all: function() {
			location.href = "superviseList.html?userid=" + _this.userid
		},
		myJingBan: function() {
			location.href = "superviseList.html?userid=" + _this.userid + "&type=jingban"
		},
		myDuban: function() {
			location.href = "superviseList.html?userid=" + _this.userid + "&type=duban"
		}
	}
})

//从url中截取传递到数据
function getUrlItem(name) { //id
	var url = location.search
	start = url.indexOf(name + "=")
	if(start != -1) {
		start = start + name.length + 1
		end = url.indexOf("&", start)
		if(end == -1) {
			end = url.length
			return unescape(url.substring(start, end))
		}
		return unescape(url.substring(start, end))
	}
	return '';
}

function getSummaryTotal(a) {
	$.ajax({
		type: "post",
		url: "http://47.92.116.158:8099/BhGgjAPI/Supervise.asmx/GetYearReport?callback=?",
		data: {
			"man": a.userid,
			"nowYear": a.nowYear
		},
		dataType: "json",
		success: function(jsondata) {
			a.summaryTotal = jsondata;
			a.summaryTotalDepart = jsondata.depart;
			a.summaryTotalWorkType = jsondata.workType;
			a.summaryTotalChaoShi = jsondata.chaoshi;
			a.summaryTotalXiuGai = jsondata.xiugai;
			console.log(jsondata)
		}
	});
}